package com.label.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.label.common.CommonResult;
import com.label.entity.Labels;
import com.label.entity.labelbind;
import com.label.entity.labelbindvo;
import com.label.service.LabelbindService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Jianhua
 * @since 2022-03-27
 */
@Api
@RestController
@RequestMapping("/api/labelbind")
public class LabelbindController {
    @Autowired
    LabelbindService labelbindService;
    @RequestMapping("/save")
    @ApiOperation("标签绑定接口")
    CommonResult save(labelbindvo labelbindvo){
        labelbindvo.setLimitstate(1);
        return CommonResult.success(labelbindService.saveOrUpdate(labelbindvo));
    }
    //id查询
    @RequestMapping("/getByid")
    @ApiOperation("根据limitid查询该标签绑定信息" )

    CommonResult getByid(Integer id){
        return CommonResult.success(labelbindService.getbindById(id));
    }
    //逻辑删除
    @RequestMapping("/del")
    @ApiOperation("标签解绑")
    CommonResult del(Integer id){
        labelbindvo labelbindvo = labelbindService.getById(id);
        labelbindvo.setLimitstate(0);
        return CommonResult.success(labelbindService.updateById(labelbindvo));
    }
    @RequestMapping("update")
    @ApiOperation("标签绑定修改")
    CommonResult update(labelbindvo labelbindvo){
        return CommonResult.success(labelbindService.update(labelbindvo));
    }
    //id查询
    //批量删除
    @RequestMapping("/delByIds")
    CommonResult delByIds(Integer[] id){
        return CommonResult.success(labelbindService.removeByIds(Arrays.asList(id)));
    }
    @RequestMapping("/labelslist")
        CommonResult selectlist(Integer id){
        System.out.println("labels"+ labelbindService.selectList(id));
            return CommonResult.success(labelbindService.selectList(id));
        }
}
